#include "imagedetaildialog.h"
#include "ui_imagedetaildialog.h"

ImageDetailDialog::ImageDetailDialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::ImageDetailDialog)
{
    ui->setupUi(this);

    // 这个非常重要，目的是为了让该View能显示所有标号的图片
    ui->widgetImage->SetFileNumber(0);

    ui->widgetImage->SetDefectInfoShow(false);
    ui->widgetImage->SetPositionInfoShow(false);
}

ImageDetailDialog::~ImageDetailDialog()
{
    delete ui;
}

void ImageDetailDialog::on_pushButtonDetailExit_clicked()
{
    this->close();
}

void ImageDetailDialog::SetImage(QString filename)
{
    ui->widgetImage->SetImage(filename);
}

void ImageDetailDialog::SetDetectionResult(SeatDetectionParameter &seatDetectionParameter,
                                           DetectionResult &detectionResult)
{
    QList<DefectInfo> &defects = detectionResult.GetResult();
    /*foreach(DefectInfo defect, defects){
    }*/
    QString strDefectNumber = QString("缺陷数量：%1").arg(defects.size());
    ui->labelInformation->setText(strDefectNumber);

    ui->widgetImage->SetDetectionResult(seatDetectionParameter, detectionResult,false);
}
